package ar.edu.utn.frsf.tpae.a2013.g04.presentation.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ar.edu.utn.frsf.tpae.a2013.g04.service.*;

/**
 * Clase de utilidad que provee acceso a instancias administradas por Spring.
 * 
 * @author TPAE
 */
public class ServiceLocator {

	private static ApplicationContext context;

	private static ApplicationContext getContext() {
		if (context == null) {
			synchronized (ServiceLocator.class) {
				if (context == null) {
					context = new ClassPathXmlApplicationContext(
							"classpath*:**/application-context-presentation.xml");
				}
			}
		}
		return context;
	}

	public static LogInService getLogInService() {
		return (LogInService) getContext().getBean("logInService");
	}
	
	public static SolicitudGastoService getSolicitudGastoService() {
		return (SolicitudGastoService) getContext().getBean("solicitudGastoService");
	}
	
	public static CentroCostoService getCentroCostoService() {
		return (CentroCostoService) getContext().getBean("centroCostoService");
	}

	
	public static EmpleadoService getEmpleadoServicee() {
		return (EmpleadoService) getContext().getBean("empleadoService");
	}
	
}
